<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>发表问题</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="fly,layui,前端社区">
    <meta name="description" content="Fly社区是模块化前端UI框架Layui的官网社区，致力于为web开发提供强劲动力">
    <link rel="stylesheet" href="__BBS_Module__/layui/css/layui.css">
    <link rel="stylesheet" href="__BBS_Module__/css/global.css">
    <script src="/public/jquery/jquery-3.3.1.min.js"></script>
    <script src="__BBS_Module__/layui/layui.js"></script>
    <link rel="stylesheet" href="/public/bbs/readarticle/select.css" crossorigin="anonymous">
    <script charset="utf-8" src="__BBS_Module__/kindeditor/kindeditor-all.js"></script>
    <script charset="utf-8" src="__BBS_Module__/kindeditor/lang/zh-CN.js"></script>
    <link rel="stylesheet" href="/public/bbs/readarticle/inserthtml.com.radios.css">
    <style>
        .mod {
            display: flex;
            align-items: center;
            /*垂直居中*/
        }
    </style>
</head>

<body>

    {$head}
    <div class="global main layui-clear">
        <div class="global fly-panel" pad20>
            <h2 class="global page-title" style="text-align: center">发表问题----发布到 {$bbs_classification_son.son_class_name}</h2>

            <!-- <div class="global fly-none">并无权限</div> -->

            <div class="global layui-form layui-form-pane">
                <form>
                    <div class="global layui-form-item">
                        <label for="L_title" class="global layui-form-label">标题</label>
                        <div class="global layui-input-block">
                            <input type="text" id="L_title" name="title" required lay-verify="required"
                                autocomplete="off" class="global layui-input">
                        </div>
                    </div>
                    <div class="global layui-form-item">
                        <label for="L_title1" class="global layui-form-label">分类</label>
                        <div class="global layui-input-block">
                            <select id="class" name="class" onchange="select_class()" class="global custom-select"
                                id="inputGroupSelect01">
                                <option value="0">请选择分类</option>
                                {volist name='bbs_article_class_list' id='vo'}
                                <option value="{$vo.id}">{$vo.class_name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="global layui-form-item">
                        <label for="L_title1" class="global layui-form-label">阅读权限</label>
                        <div class="global layui-input-block">
                            <select name="inputGroupSelect02" class="global custom-select" id="inputGroupSelect02">
                                <option value="0">请选择权限</option>
                                {volist name='bbs_jurisdiction_level' id='vo'}
                                <option value="{:rsa_encode($vo['id'])}">{$vo.level_name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>

                    <div class="global layui-form layui-form-pane">
                        <div class="global layui-form-item layui-form-text">
                            <div class="global layui-input-block">
                                <textarea id="textarea" name="content"
                                    placeholder="{$web_settings['bbs_publish_articles_articles_text']}"
                                    class="global layui-textarea fly-editor" style="height: 350px;"
                                    style="width:700px;height:300px;">{$web_settings['bbs_publish_articles_articles_text']}</textarea>
                            </div>
                        </div>

                    </div>
                </form>
                <div class="global layui-form-item">
                    <button class="global layui-btn" lay-filter="*" onclick="release()" lay-submit>发表</button>
                    <div class="global mod" style=' float: right;'>
                        有人评论时邮件通知我
                        <div id="comment_email_notification" class="global mod">
                            <input type="checkbox" value="0" id="comment_email_notification_input" lay-skin="switch"
                                lay-text="开启|关闭">
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>

    <script type="text/javascript">
        var editor;
        KindEditor.ready(function (K) {
            editor = K.create('#textarea', {
                resizeType: 2,
                uploadJson: '{:url("upload/index/image_upload")}', // 相对于当前页面的路径
                newlineTag: 'br', //回车换行br|p
                afterBlur: function () {
                    editor.sync();
                    if (editor.html() == '<br />' || editor.html() == '') {
                        editor.html("{$web_settings['bbs_publish_articles_articles_text']}");
                        $("#qstContent").contents().find(".ke-content").css("color", "red");
                    }
                },
                afterFocus: function () {
                    if (editor.html() == "{$web_settings['bbs_publish_articles_articles_text']}") {
                        editor.html('');
                        // 输入文字变为黑色
                        $("#qstContent").contents().find(".ke-content").css("color", "#fff");
                    }
                },
            });
        });

        layui.use('form', function () {
            var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        });
        $('#comment_email_notification').click(function (e) {
            e.preventDefault();
            if ($('#comment_email_notification_input').val() == 0) {
                $('#comment_email_notification_input').val(1);
            } else {
                $('#comment_email_notification_input').val(0);
            }

        });

        function release() {
            var options = $("#inputGroupSelect02 option:selected"); //获取选中的项
            $val = options.val(); //拿到选中项的值
            $text = options.text(); //拿到选中项的文本
            $.ajax({
                type: "POST",
                url: "{:url('bbs/publish_articles/release')}",
                data: {
                    "L_title": $('#L_title').val(),
                    "class": $('#class').val(),
                    "textarea": $('#textarea').val(),
                    'RandStr': '{$RandStr}',
                    'comment_email_notification': $('#comment_email_notification_input').val(),
                    'ReleaseAlias': '{$ReleaseAlias}',
                    'jurisdiction_number': $val,
                    'jurisdiction_name': $text,
                },
                dataType: "json",
                success: function (response) {

                }
            });
        }
    </script>
</body>

</html>